package com.example.microservice.common.base;

import java.io.Serializable;
import java.util.Objects;

import org.apache.poi.ss.formula.functions.T;

/**
 * This is Description
 *
 * @author sun
 * @date 2018/11/14
 * @Description 返回值包装类
 */
public class RestResponse<T> implements Serializable {


    private static final long serialVersionUID = 7044647402050729984L;
    /**
     * 响应头中的 HTTP 状态码
     */

    private Integer status=200;


    /**
     * 你提供的特定 REST API 的异常编码。它通常传达有关问题域的非常具体的信息
     */
    private Integer code = 1;

    /**
     * 错误信息
     */
    private String message = "success";

    /**
     * 数据
     */
    private T data;




    public RestResponse() {

    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof RestResponse)) return false;
        RestResponse that = (RestResponse) o;
        return Objects.equals(status, that.status) &&
                Objects.equals(code, that.code) &&
                Objects.equals(message, that.message) &&
                Objects.equals(data, that.data);
    }

    @Override
    public int hashCode() {

        return Objects.hash(status, code, message, data);
    }
}
